package java学习.实训.day06.program;

import java.util.Scanner;

/**
 * **************
 * 项目名称: 蓝桥杯 <br/>
 * 文件名称:  <br/>
 * 文件描述: 这里添加您的类文件描述，说明当前文件要包含的功能。 <br/>
 * 文件创建：刘世锦 <br/>
 * 创建时间: 2022/6/14 <br/>
 *
 * @version v1.0 <br/>
 * @update [序号][日期YYYY-MM-DD][更改人姓名][变更描述]<br/>
 * *************
 */
public class Main {
//    ●·●•☻◘★◆▸﹫©•·●✺ฅ●•●@
    public  static final String BLACK = "©".toUpperCase();
    public  static final String WHITE = "O";

    public static void main(String[] args) {
        int x;
        int y;
        int loop = 0;
        Chessboard chessboard = new Chessboard();
        chessboard.initChessBord();
        Rule rule = new Rule();

        Scanner sc = new Scanner(System.in);
        while (loop==0){
            chessboard.printChessBord();
            System.out.println("请输入下黑棋的坐标:");
            x = sc.nextInt();
            y = sc.nextInt();
            Piece hpiece = new Piece(x, y, Main.BLACK);
            boolean ispiece = chessboard.fallPiece(hpiece);
            while (ispiece){
                System.out.println("该位置已有棋子，请重新输入");
                System.out.println("请输入下黑棋的坐标:");
                x = sc.nextInt();
                y = sc.nextInt();
                ispiece = chessboard.fallPiece(new Piece(x, y, Main.BLACK));
            }
            if (rule.checkWin(hpiece)){
                chessboard.printChessBord();
                System.out.println("黑棋获胜！");
                break;
            }

            chessboard.printChessBord();
            System.out.println("请输入下白棋的坐标:");
            x = sc.nextInt();
            y = sc.nextInt();
            Piece bpiece = new Piece(x, y, Main.WHITE);


            boolean isfallPiece = chessboard.fallPiece(bpiece);
            while (isfallPiece){
                System.out.println("该位置已有棋子，请重新输入");
                System.out.println("请输入下白棋的坐标:");
                x = sc.nextInt();
                y = sc.nextInt();

                isfallPiece = chessboard.fallPiece(new Piece(x, y, Main.WHITE));
            }
            if (rule.checkWin(bpiece)){
                chessboard.printChessBord();
                System.out.println("白棋获胜！");
                break;
            }
//            chessboard.printChessBord();
        }
//
//
//        chessboard.fallPiece(new Piece(4,5,"©"));
//        chessboard.fallPiece(new Piece(2,6,"O"));
//        chessboard.printChessBord();

    }
//●o ⊕✦❁●◕◆◉◙■▗◾☪©☢☯㊣┖

}
